const digits:array[1..36] of char=('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
function dectofrac(p:integer; n:string):string;
var count,index:int64; s:string; current:extended; i,j:longint;
begin
current:=0;
count:=1;
for i:=length(n) downto 1 do begin
  for j:=1 to 36 do if digits[j]=n[i] then index:=j-1;
  current:=current+index*count;
  count:=count*10;
end;
while current>=1 do current:=current/10;
i:=1;
while n[i]='0' do begin
  current:=current/10;
  inc(i);  
end;
s:='';
if n='0' then s:='0';
count:=0;
while count<10 do begin
  inc(count);
  current:=current*p;
  s:=s+digits[trunc(current)+1];
  current:=current-trunc(current);
end;
result:=s;
end;